-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block CSS: Move CSS from the stylesheet to the block definition #41689
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great start 🚢
Size Change: -16 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
The rule (margin: 0 0 1em 0) seems to be applied, testing an emtpy theme. Block-CSS-styles-in-block-json.mp4 |
@bph I think that's expected, what did you expect? |
Yes. I didn't find anything not working. Confirming all as expected. 👏👏🚀👍 |
Yes. I didn't find anything not working. Confirming all as expected. 👏👏🚀👍 |
Thank you, that's very helpful :) |
The change here seems good. Howeover I'm encountering some awkward default margins as a result in TT2: Essentially the In other words, the default bottom margin here conflicts with the owl selector ( Is that expected, or are there ways we can tweak this? Should the specificity be reduced one place or another, or increased for the owl selector? If I remove the new theme.json rules, things look good in TT2: But of course we risk resurfacing #29517. |
I think ideally the default margins provided by the blocks should have a lower specificity, rather than us increasing the specificity of the layout support. There's a semi-related issue for when folks do want margins to override layout styles (#43404) for which a solution might be to lower the specificity of the layout styles, but it's a challenging thing to do when wrestling with the block's default values, too. I'm not too sure how we get there, but from my perspective I think we'd want something like:
|
I created a PR to try to fix this bug here: #43792 |
I added the label |
@bph we did publish a post about it already: https://make.wordpress.org/core/2022/08/01/moving-core-block-styling-to-json/ Is that sufficient? |
I think this is covered by the dev note here: #34180 (comment) |
What?
This moves the margin CSS for these 5 blocks from the stylesheet to the block.json file.
Why?
Now if a theme wants to override these rules they don't need to worry about CSS specificity, the rules in theme.json will simply change these values. This will also result in less CSS overall.
Testing Instructions
@WordPress/block-themers